-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updates theme_json_*
filter names with ending *_data
#3443
Conversation
@@ -180,7 +180,7 @@ public static function get_core_data() { | |||
* | |||
* @param WP_Theme_JSON_Data Class to access and update the underlying data. | |||
*/ | |||
$theme_json = apply_filters( 'theme_json_default', new WP_Theme_JSON_Data( $config, 'default' ) ); | |||
$theme_json = apply_filters( 'theme_json_default_data', new WP_Theme_JSON_Data( $config, 'default' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another idea might be to follow a theme_json_data_{$context}
syntax:
$theme_json = apply_filters( 'theme_json_default_data', new WP_Theme_JSON_Data( $config, 'default' ) ); | |
$theme_json = apply_filters( 'theme_json_data_default', new WP_Theme_JSON_Data( $config, 'default' ) ); |
@@ -490,7 +490,7 @@ public static function get_user_data() { | |||
* | |||
* @param WP_Theme_JSON_Data Class to access and update the underlying data. | |||
*/ | |||
$theme_json = apply_filters( 'theme_json_user', new WP_Theme_JSON_Data( $config, 'custom' ) ); | |||
$theme_json = apply_filters( 'theme_json_user_data', new WP_Theme_JSON_Data( $config, 'custom' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit unrelated, but it's odd that custom
is used here which isn't documented in https://github.com/wordpress/wordpress-develop/blob/711b74c21bef856677fd97d82d17f7761d0d602a/src/wp-includes/class-wp-theme-json-data.php#L40.
Should we consider putting Not sure about adding the |
Test failures are unrelated to this PR and are currently present in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 Ready for commit
Committed via changeset https://core.trac.wordpress.org/changeset/54501. Thank you everyone for your contributions 🎉 |
This PR needs a few follow-ups:
I've prepared WordPress/gutenberg#44940 to address the last two items. Would anyone be available for review? |
@@ -1899,7 +1899,7 @@ protected static function get_style_nodes( $theme_json, $selectors = array() ) { | |||
* | |||
* @param array $nodes Style nodes with metadata. | |||
*/ | |||
return apply_filters( 'theme_json_get_style_nodes', $nodes ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@scruffian @ajlende @draganescu I see that, in Gutenberg land, we name this filter gutenberg_theme_json_style_nodes
. Do we need to take any action here? I haven't seen that we prefix the filters depending on environment (wp_
or gutenberg_
) in any other case. My understanding is that it's problematic for any consumer that want to use the filter. Though this rationale may have changed, so I've excluded this from WordPress/gutenberg#44940 and can be looked at separately, if necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for flagging this @oandregal. I don't see any specific reason for using a different filter in the plugin vs core. I'll open a PR to match this.
EDIT: Opened WordPress/gutenberg#44949
Adding
_data
to filter names.https://core.trac.wordpress.org/ticket/56796